﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity.Infrastructure;
using System.Data.Objects;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;

namespace IGIS
{
    public class PolygonController : ApiController
    {
        // GET api/<controller>
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/<controller>/5
        public TBL_Project Get(decimal id)
        {
            using (HetzEntities db =new HetzEntities())
            {
              return  db.TBL_Project.FirstOrDefault(x => x.PolygonID == id);
                
            }
        
        }

        // POST api/<controller>
        public void Post([FromBody]string value)
        {
        }
     //   [HttpPost]
        /*public ContentResult Upload(HttpPostedFileBase file)
        {
            var filename = Path.GetFileName(file.FileName);
            var path = Path.Combine(Server.MapPath("~/uploads"), filename);
            file.SaveAs(path);

            return new ContentResult
            {
                ContentType = "text/plain",
                Content = filename,
                ContentEncoding = Encoding.UTF8
            };
        }*/
        // PUT api/<controller>/5
        public string  Put(TBL_Project polygon)
        {
            /*if (!_customers.Update(TBL_Project))
                throw new HttpResponseException(HttpStatusCode.NotFound);*/
            try
            {
                using (HetzEntities db = new HetzEntities())
                {
                 
                    db.Entry(polygon).State = EntityState.Modified;
                    db.SaveChanges();


                }
                //   return customer;
                return "נשמר בהצלחה";
            }
            catch(Exception edd) {
                return edd.Message;
            
            }

        }

        // DELETE api/<controller>/5
        public void Delete(int id)
        {
        }
    }
}